<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>CMS</title>
<link href="__CSS__/common.css" rel="stylesheet"/>
<link href="__CSS__/right.css" rel="stylesheet"/>
<link rel="stylesheet" href="__INC__/form/css/zebra_form.css" type="text/css">
<script type="text/javascript" language="javascript" src="__JS__/jquery-1.7.2.min.js"></script>
<script type="text/javascript" language="javascript" src="__JS__/FusionCharts.js"></script>
<script type="text/javascript" language="javascript" src="__JS__/common.js"></script>
<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        $(".table_list tr").mouseover(function () {
            $(this).addClass("one");
        })
        $(".table_list tr").mouseout(function () {
            $(this).removeClass("one");
        })
    });
</script>
<style type="text/css">
    .one {
        background: #fcfcfc;
    }
</style>
<style type="text/css">
    #panel {
        width: 100%;
    }

    .infos_left {
        float: left;
        width: 700px;
    }

    .infos_right {
        width: 150px;
        float: right;
        margin-right: 150px;
    }

    .category td {
        border-bottom: 1px dotted #CCC;
        border-width: 1px 0;
    }
</style>
</head>
<body>
<!--右侧区域 begin-->
<div class="right">
    <!--当前位置 begin-->
    <include file='common:crumbs'/>
    <!--当前位置 end-->
    <!--主体区域 begin-->
    <div class="container">
        <div class="alert_div">
            <h4 class="alert_info"><span class="welcome">{$welcome}</span>您现在的位置是：{$current} </h4>
            <h4 class="alert_what" style="display:none;"></h4>
        </div>
        <!--样式一 begin-->
        <div class="stats">
            <div class="lm_title">
                <div class="lm_title_l">
                    <em>操作面板</em>
                </div>
            </div>
            <div class="lm_content">
                <div id="panel">
                    <div class="infos_left">
                        <table class="Zebra_Form">
                            <tr class="row">
                                <td><label>指定种类:</label></td>
                                <td>
                                    <select id="ftypeid" class="control" onchange="changeType(this)">
                                        {$select_html}
                                    </select>
                                </td>
                                <td><label>快捷操作:</label></td>
                                <td><input type="button" class="button" onclick="addcontent()" value="添加属性"/></td>
                                <td><input type="button" class="button" onclick="openpanel('del')" value="批量删除"/></td>
                                <td><input type="button" class="button" onclick="setOrder()" value="保存排序"/></td>
                            </tr>
                        </table>
                    </div>
                    <div class="infos_right">{$chart_html}</div>
                    <div class="clear"></div>
                </div>
            </div>
            <div class="lm_bottom">
                <div class="lm_bottom_l">
                    <em></em>
                </div>
            </div>
        </div>
        <!--样式一 end-->
        <!--样式二 begin-->
        <div class="stats">
            <div class="lm_title">
                <div class="lm_title_l">
                    <em>{$current}</em>
                </div>
            </div>
            <div class="lm_table">
                <table cellpadding="0" cellspacing="0" width="100%" class="table_list">
                    <tr class="title" align="left">
                        <td>选择</td>
                        <td>ID</td>
                        <td align="left" style="text-align:left;">属性名称</td>
                        <td>商品类型</td>
                        <td>属性值的录入方式</td>
                        <td>可选值列表</td>
                        <td>排序</td>
                        <td>操作</td>
                    </tr>
                    <volist name='list' id='arr'>
                        <!--tr class="tr_line">
                            <td colspan="10"><div></div></td>
                        </tr-->
                        <tr align="left" class="category">
                            <td><input type="checkbox" name="_check[]" value="{$arr['id']}"></td>
                            <td>{$arr['id']}</td>
                            <td align="left">&nbsp;{$arr['name']}</td>
                            <td>{:getGoodsTypeName($arr['fid'])}</td>
                            <td>{:attrInputType($arr['input_type'])}</td>
                            <td width="30%" align="left">{:msubstr($arr['values'],0,40)}</td>
                            <td><input type="text" class="text orderid" _id="{$arr['id']}" value="{$arr['order']}" maxlength='3' style="width:30px;"/></td>
                            <td><a href="edit?attr_id={$arr['id']}">修改</a> | <a href="javascript:void(0)" onclick="openpanel('del','{$arr['id']}')">删除</a></td>
                        </tr>
                    </volist>
                </table>
            </div>
            <div class="lm_table_bottom">
                <div class="lm_table_bottom_l">
                    <em>
                        <div class="select_btn"><input type="button" class="select_btn1" onclick="selAll()" value=""/>&nbsp;&nbsp;<input
                                type="button" onclick="selRev()" class="select_btn2" value=""/></div>
                        <div class="page">{$page}</div>
                        <div class="clear"></div>
                    </em>
                </div>
            </div>
        </div>
        <!--样式二 end-->
    </div>
    <!--主体区域 end-->
</div>
<!--右侧区域  end-->

<!--弹出层二begin-->
<div class="popupPanel">
    <div class="stats">
        <div class="lm_title">
            <div class="lm_title_l"><em class="panelTitle">做什么？</em></div>
        </div>
        <div class="lm_content">
            <table class="Zebra_Form" style="width:100%;">
                <tr class="row">
                    <td width="60"><label>已选ID：</label></td>
                    <input type="hidden" class="controlitems" value=""></input>
                    <input type="hidden" class="panelaction" value=""></input>
                    <td colspan="2" class="checked_items"><label style="color:#FF00AE;"></label></td>
                </tr>
                <tr class="row">
                    <td></td>
                    <td><input type="button" onclick="panelDo()" class="button" value="确定"/></td>
                    <td><input type="button" class="button" onclick="panelClose()" value="取消"/></td>
                </tr>
            </table>
        </div>
        <div class="lm_bottom">
            <div class="lm_bottom_l"><em></em></div>
        </div>
    </div>
</div>
<!--弹出层二end-->
</body>
<script>
    function addcontent() {
        location.href = "__GROUP__/attribute/add?gtid={$gtid}";
    }

    function changeType(o) {
        location.href = "__GROUP__/attribute/show?gtid=" + $(o).val();
    }

    //开启panel窗口
    function openpanel(act, item, name) {
        //初始化关闭所有附加panel
        if (item === undefined || typeof(item) == 'undefined') {
            item = getSelects();
        }

        if (item == '') {
            jl_notify(3, "你没有选中任何项！");
            return;
        }

        $(".controlitems").val(item);
        $('.checked_items label').text(item);
        if (act == 'del') {
            $(".panelTitle").text("你确定要删除这些属性？");
            $(".panelaction").val("del");
            var obj = $('.popupPanel');
            jl_fadeIn(obj);
        } else {
            jl_notify(3, "不知道你到底要干什么！");
            return;
        }
    }

    //关闭panel窗口
    function panelClose() {
        var obj = $('.popupPanel');
        jl_fadeOut(obj);
    }

    //panel执行操作
    function panelDo() {
        var act = $(".panelaction").val();
        if (act == '') {
            jl_notify(3, "不知道你到底要干什么！");
            return;
        }

        if (act == 'del') {
            jl_fadeOut($('.popupPanel'));
            var items = $(".controlitems").val();
            $.post("__GROUP__/shopajax/delattribute", {
                items: items
            }, function (data) {
                if (data == -1) {
                    jl_notify(2, "呜呜，删除这些属性失败！");
                } else if (data == -3) {
                    jl_notify(3, "有商品正在使用该属性！");
                } else if (data == 1) {
                    //jl_notify(1,"嘻嘻，删除栏目成功！");
                    location.href = location.href;
                } else {
                    jl_notify(2, "呜呜，种种原因导致删除这些属性失败！");
                }
            })
        } else {
            jl_notify(3, "不知道你到底要干什么！");
            return;
        }
    }


    //批量排序
    function setOrder() {
        var orderjson = '';
        $(".orderid").each(function (e) {
            var id = $(this).attr("_id");
            var v = $(this).val();
            if (orderjson != '') orderjson = orderjson + ',';
            orderjson += "'" + id + "':'" + v + "'"
        })

        orderjson = "{" + orderjson + "}";
        orderjson = eval('(' + orderjson + ')');
        $.post("__GROUP__/shopajax/SetOrderCommon", {json: orderjson, table: 'attribute'}, function (data) {
            if (data == -1) {
                jl_notify(2, "呜呜，排序设置失败！");
            } else if (data == -2) {
                jl_notify(3, "嘿，排序序号不要有重复的值撒！");
            } else {
                location.href = location.href;
            }
        })
    }
</script>
</html>
